<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/12/11
 * Time: 15:04
 */

namespace app\modules\responsibilitiesChain\controller;

use app\modules\responsibilitiesChain\Director;
use app\modules\responsibilitiesChain\GeneralManager;
use app\modules\responsibilitiesChain\Manager;
use app\modules\responsibilitiesChain\Request;
use yii\web\Controller;

class DefaultController extends Controller
{
    /**
     * 责任链模式示例
     * 建立一个对象链来按指定顺序处理调用。如果其中一个对象无法处理命令，它会委托这个调用给它的下一个对象来进行处理，以此类推
     *
     * @date   2018/12/11
     * @author edmmss
     * @return bool
     */
    public function actionIndex()
    {
        $generalManager = new GeneralManager();
        $director = new Director($generalManager);
        $manager = new Manager($director);

        $request = new Request('加薪');
        $result = $manager->handle($request);

        var_dump($result);

        return true;
    }
}